package com.bbx.flink.demo.read_text;

import lombok.extern.slf4j.Slf4j;
import org.apache.flink.api.java.io.TextInputFormat;
import org.apache.flink.core.fs.Path;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;

@Slf4j
public class ReadTextDemo {


    public static void main(String  [] args) throws Exception {
        String  filePath = "D:\\TestWorkspace\\FlinkDemoAll\\src\\main\\resources";
        //获取执行环境
        StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
        //获取数据源
//        DataStreamSource<String> stringDataStreamSource = env
//                .readTextFile(filePath);


//        DataStreamSource<String> stringDataStreamSource = env
//                .readFile(new TextInputFormat(new Path(filePath)), filePath);
//
//        DataStreamSource<String> stringDataStreamSource = env
//                .readFile(new TextInputFormat(new Path(filePath)), filePath, FileProcessingMode.PROCESS_CONTINUOUSLY,15000);

        // 数据输出
        env.readFile(new TextInputFormat(new Path(filePath)), filePath).print();
//        stringDataStreamSource.writeAsText("D:\\TestWorkspace\\FlinkDemoAll\\src\\main\\resources\\aaaaaaa.txt");        //执行
        env.execute("readTex");
        log.info("[{}]~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");

    }

}
